<template>
  <elm-page-tb>
        <template #top>
          <elm-row>
            <el-input placeholder="请查询输入内容" prefix-icon='el-icon-search' size="mini" style="width: 250px;margin: 0 10px" v-model="postData.name" clearable></el-input>
            <elm-ei size="mini" style="width: 250px;margin: 0 10px" v-model="postData.user" clearable></elm-ei>
            <div></div>
            <right>
              <el-button-group>
                <el-button icon="el-icon-search" size="mini" @click="tablebinding()">查询</el-button>
              </el-button-group>
            </right>
          </elm-row>
        </template>
        <elm-table url="/business/plm/plan/task/GetData" :post-data="postData" :page-size="50" height="100%" v-if="now_user">
            <el-table-column prop="name" label="工作名称" header-align="center"></el-table-column>
            <el-table-column prop="plan_name" label="计划名称" header-align="center"></el-table-column>
            <el-table-column prop="jh_start_time" :formatter="formatDateTime" label="计划开始时间" align="center" width="160"></el-table-column>
            <el-table-column prop="jh_end_time" :formatter="formatDateTime" label="计划结束时间" align="center" width="160"></el-table-column>
            <el-table-column prop="priority" label="优先级" align="center" width="100"></el-table-column>
            <el-table-column prop="status" label="状态" align="center" width="100"></el-table-column>
            <el-table-column prop="assignee_id" label="负责人" align="center" width="120">
              <template v-slot="scope">
                {{ eiList.find(item => item.key === scope.row.assignee_id)?.value || '未分配' }}
              </template>
            </el-table-column>
          <el-table-column fixed="right" label="填报" width="100px" align="center">
            <template v-slot="scope">
              <elm-open-button url="plan_stage" title="工作填报" width="800" height="40%"
                               :data="{ plan_id:scope.row.id }" type="text">填报</elm-open-button>
            </template>
          </el-table-column>
        </elm-table>
    </elm-page-tb>
</template>

<script>
export default {
    extends: elmVueBase,
    data() {
        return {
          postData: {name: null,user: null},
          now_user:null,
          eiList:[]
        }
    },
    async created() {
      this.postData.user=await this.get_user_ei();
      this.eiList = await this.get_ei();
      this.now_user=this.postData.user;
    },
    methods: {
      async get_ei(){
        var res = await elm.post('/business/my/business/GetEi');
        //console.log(res);
        if(res.length>0)
          return res;
        else
          return [];
      },
      async get_user_ei(){
        var res = await elm.post('/system/login/GetUserEi');
        if(res.length>0)
          return res[0].emp_code;
        else
          return "";
      },
    }
}
</script>

<style scoped>
</style>